#include "UdpServer.hpp"


int main(int argc, char* argv[])
{
    if(argc != 2){
        // LOG(LogLevel::FATAL) 
        std::cerr << "Usage: " << argv[0] << " PORT" << std::endl;
        Die(err::USE_ERR);
    }

    uint16_t port = std::stoi(argv[1]);
    
    LOG_CONSOLE;

    std::shared_ptr<Dictionary> dict_sptr = std::make_shared<Dictionary>();
//                                                                     引用抓取
    std::unique_ptr<UdpServer> svr_uptr = std::make_unique<UdpServer>([&dict_sptr](std::string word){
        std::cout << '|' << word << '|' << std::endl;
        return dict_sptr->Translate(word);
    },port);
    svr_uptr->InitServer();
    svr_uptr->Start();

    return 0;
}